﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="../Plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <link href="../zui/lib/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../Plugins/keyboard/css/keyboard.min.css" rel="stylesheet" />
    <link href="../zui/css/font-awesome.min.css" rel="stylesheet" />
    <link href="../zui/css/zui.min.css" rel="stylesheet" />
    <link href="../Plugins/jquery-step/jquery.steps.css" rel="stylesheet" />
    <link href="../Plugins/sweetalert/sweetalert.css" rel="stylesheet" />
    <link href="../zui/css/app.css" rel="stylesheet" />
    <style type="text/css">
        body {
            font-size: 16px !important;
        }

        .panel-primary > .panel-heading {
            border-radius: 0px;
        }

        .panel {
            margin-bottom: 2px;
        }

        .syxx {
            width: 200px;
            margin-top: 15px;
        }

            .syxx button {
                height: 35px;
            }

        .syxx1 {
            margin-top: 12px;
            margin-left: 35px;
        }

            .syxx1 button {
                width: 120px;
                height: 55px;
            }

        .highcharts-credits {
            display: none !important;
        }

        .chart-content {
            margin-bottom: 5px;
            box-shadow: 0 3px 4px #ddd;
        }

        .recordMark {
            color: green
        }
        #webcam img {
            width: 640px !important;
            height: 330px !important;
        }
    </style>
    <script type="text/javascript">

        /* Copyright (C) 2007 Richard Atterer, richardĀ©atterer.net
           This program is free software; you can redistribute it and/or modify it
           under the terms of the GNU General Public License, version 2. See the file
           COPYING for details. */

        var imageNr = 0; // Serial number of current image
        var finished = new Array(); // References to img objects which have finished downloading
        var paused = false;

        function createImageLayer() {
            var img = new Image();
            img.style.position = "absolute";
            img.style.zIndex = -1;
            img.onload = imageOnload;
            img.onclick = imageOnclick;
            img.src = "http://127.0.0.1:8080/?action=snapshot&n=" + (++imageNr);
            var webcam = document.getElementById("webcam");
            webcam.insertBefore(img, webcam.firstChild);
        }

        // Two layers are always present (except at the very beginning), to avoid flicker
        function imageOnload() {
            this.style.zIndex = imageNr; // Image finished, bring to front!
            while (1 < finished.length) {
                var del = finished.shift(); // Delete old image(s) from document
                del.parentNode.removeChild(del);
            }
            finished.push(this);
            if (!paused) createImageLayer();
        }

        function imageOnclick() { // Clicking on the image will pause the stream
            paused = !paused;
            if (!paused) createImageLayer();
        }

    </script>
</head>
<body onload="createImageLayer();">
    <div id="videoControl" style="width:870px;height:330px;background-color:#FFF;border:2px solid double;z-index:9999999!important;position:absolute;display:none">
        <div id="webcam" style="width:640px;left:0px;height:330px;position:absolute;z-index:999999999;background-color:#808080"><noscript><img src="http://127.0.0.1/?action=snapshot" /></noscript></div>

        <div style="width:230px;right:0px;height:330px; overflow:hidden; position:absolute">
            <div class="ControlMask" style="width:230px;right:0px;height:330px;position:absolute;z-index:999999999;opacity:0.5;background-color:#808080"></div>
            <div class="panel panel-primary" style="border-radius:0px !important" disabled="disabled">
                <div class="panel-heading">视频录制控制</div>
                <div class="panel-body" style="height:83px;text-align:center;line-height:35px;padding:0px">
                    <input type="hidden" id="VideoRecordStatus" value="0" />
                    <span class="VideoRecordStatusTxt">未在录制</span><br />
                    <button class="btn btn-success RecordVideo" type="button">开始录制</button> <button class="btn OpenVideoPath" type="button">打开目录</button> <button class="btn OpenLight" val="0" type="button">开灯</button>
                </div>
            </div>
            <div class="panel panel-primary" style="border-radius:0px !important">
                <div class="panel-heading">试验现象确认</div>
                <div class="panel-body" style="height:160px;padding-top:0px !important;padding-bottom:0px !important">
                    <div class="btn-group btn-group-vertical syxx">
                        <button type="button" class="btn stopExperiment" value="1">试样爆炸</button>
                        <button type="button" class="btn stopExperiment" value="2">试样燃烧</button>
                        <button type="button" class="btn stopExperiment" value="3">试样变色</button>
                        <button type="button" class="btn stopExperiment" value="0">无变化</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <div id="sycontent" style="height:302px; overflow-y:scroll; overflow-x:hidden !important">
        <div class="row" style="color:#f1a325">
            <div class="col-xs-4">
                试验材料：<span id="Sycl"></span>
            </div>
            <div class="col-xs-4">
                设定温度：<span id="Sywd">75</span>℃
            </div>
            <div class="col-xs-4">
                设定试验时长：<span id="Sysc">48</span>
            </div>
        </div>
        <hr style="border-color:#d0c8c8" />
        <div class="row shiyan-status" style="color:#f1a325;margin-top:15px;height:120px;overflow-y:hidden">
            <div class="col-xs-4">
                <div style="margin-left:68px"><img src="../static/images/shiyan1.png" /></div>
            </div>
            <div class="col-xs-8">
                <div style="font-size:20px;margin-top:10px">请将试样放入烘箱中，并关闭烘箱门，准备就绪后开始试验！</div>
            </div>
        </div>
        <div class="row shiyan-status" style="color:#f1a325;margin-top:15px;height:120px;display:none;overflow-y:hidden">
            <div class="col-xs-4" style="margin-top:10px;">
                <div style="width:90px;height:90px;" class="sk-spinner sk-spinner-rotating-plane"></div>
            </div>
            <div class="col-xs-8">
                <div style="font-size:20px;margin-top:18px">正在整定温度...</div>
                <div><span class="shiyan-hxwd" style="font-size:20px">获取温度中...</span><span style="font-size:20px;display:none">   </span></div>
            </div>
        </div>
        <div class="row shiyan-status" style="color:#f1a325;margin-top:15px;height:120px;display:none;overflow-y:hidden">
            <div class="col-xs-4" style="margin-top:10px;">
                <div style="width:90px;height:90px;" class="sk-spinner sk-spinner-rotating-plane"></div>
            </div>
            <div class="col-xs-8">
                <div style="font-size:20px;margin-top:18px;display:none">正在试验中...</div>
                <div><span id="shiyan-time" style="font-size:20px">试验已用时：0分0秒</span><span style="font-size:20px;display:none">  正在试验中... </span></div>
                <div><span class="shiyan-hxwd" style="font-size:20px">获取温度中...</span><span style="font-size:20px;display:none">   </span></div>
            </div>
        </div>
        <hr />
        <div class="ibox float-e-margins" style="width:870px;">
            <div class="ibox-content">
                <div style="background-color:#FFF;border:2px solid double;position:relative; box-shadow: 0 3px 4px #ddd;">
                    <div class="ControlMask" style="top:0px;width:870px; height:191px;position:absolute;z-index:99!important;opacity:0.5;background-color:#808080"></div>
                    <div class="row">
                        <div class="col-xs-4" style="margin-bottom:15px">
                            <div class="panel panel-primary" style="border-radius:0px !important" disabled="disabled">
                                <div class="panel-heading">视频录制控制</div>
                                <div class="panel-body" style="height:120px;text-align:center;line-height:35px;padding:0px">
                                    <input type="hidden" id="VideoRecordStatus" value="0" />
                                    <div style="height:20px"></div>
                                    <span class="VideoRecordStatusTxt">未在录制</span><br />
                                    <button class="btn btn-success RecordVideo" type="button">开始录制</button> <button class="btn OpenVideoPath" type="button">打开视频目录</button>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-8" style="margin-bottom:15px">
                            <div class="panel panel-primary" style="border-radius:0px !important">
                                <div class="panel-heading">试验现象确认</div>
                                <div class="panel-body" style="height:120px">
                                    <div class="btn-group syxx1">
                                        <button type="button" class="btn stopExperiment" value="1">试样爆炸</button>
                                        <button type="button" class="btn stopExperiment" value="2">试样燃烧</button>
                                        <button type="button" class="btn stopExperiment" value="3">试样变色</button>
                                        <button type="button" class="btn stopExperiment" value="0">无变化</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <hr />
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h3 id="bh">温度监测</h3>
                <div class="ibox-tools">
                </div>
            </div>
            <div class="ibox-content">
                <div class="flot-chart">
                    <div class="chart-content" id="flot-line-chart-moving1" style="width:870px;height:200px"></div>
                </div>
                <div class="flot-chart" style="display:none">
                    <div class="chart-content" id="flot-line-chart-moving2" style="width:870px;height:200px"></div>
                </div>
            </div>
        </div>



    </div>
    <div class="shiyan-footer" style="padding-bottom:-10px !important;margin-bottom: 8px;">
        <button style="height:50px;float:left;margin-right:5px" class="btn btn-danger home-btn" type="button">退出试验</button>
        <!--<button style="float:left;margin-right:5px" class="btn btn-default fm-btn" type="button">开启阀门</button>-->
        <button style="height:50px;float:left;margin-right:5px" class="btn btn-default sxt-btn" type="button">查看实时图像</button>
        <!--<button style="float:left" class="btn btn-default splj-btn" type="button">视频目录配置</button>-->
        <button style="height:50px;float:right" class="btn btn-primary start-shiyan" type="button">开始试验</button>
    </div>
    <script src="../zui/lib/jquery/jquery.js"></script>
    <script src="../zui/js/socket.io.min.js"></script>
    <script src="../Plugins/jquery-ui/jquery-ui.min.js"></script>
    <script src="../Plugins/keyboard/js/jquery.keyboard.min.js"></script>
    <script src="../Plugins/keyboard/js/jquery.mousewheel.min.js"></script>
    <script src="../Plugins/keyboard/js/jquery.keyboard.extension-mobile.min.js"></script>
    <script src="../Plugins/sweetalert/sweetalert.min.js"></script>
    <script src="../Plugins/Highcharts-6.1.0/code/highcharts.js"></script>
    <script src="../Plugins/Highcharts-6.1.0/code/modules/exporting.js"></script>
    <script src="../Plugins/Highcharts-6.1.0/code/modules/export-data.js"></script>
    <script src="../Plugins/jquery-step/jquery.steps.min.js"></script>
    <script src="../zui/lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="../zui/lib/swiper/js/swiper.min.js"></script>
    <script src="../zui/lib/layer/layer.js"></script>
    <script src="../zui/js/utils.js"></script>
    <script src="../zui/js/app.js"></script>
    <script type="text/javascript">
        var shiyan = true;
        var t = 0;
        var index = getQueryString("index");
        //实验ID
        var experimentStepId = "";
        var socket;
        //试样温度
        var temp1 = 0;
        //腔体温度（主）
        var temp2 = 0;
        //腔体温度（辅 PID）
        var temp3 = 0;
        //稳定温度
        var temp4 = 0;
        var kg = 0;
        var fq = 0;
        var kgMark = 0;
        var fqMark = 0;
        var kgStartTime = 0;
        var fqStartTime = 0;
        var tempStatus = 0;
        var startTime = 0;
        var currentShiYanTime = 0;
        var startExperimentMark = false;
        $(function () {
            Highcharts.setOptions({
                　　global: {
                    　　　　timezoneOffset: -8 * 60
                　　　　　　}
            });
            $(".syIndex").text(index);
            $("#Sycl").text(sessionStorage.Sycl);
            $("#Sywd").text(sessionStorage.Sywd);
            $("#Sysc").text(sessionStorage.Sysc);
            $(".RecordVideo").click(function () {

                if ($("#VideoRecordStatus").val() == 0) {
                    $("#VideoRecordStatus").val(1);
                    $(".RecordVideo").text("停止录制").removeClass("btn-success").addClass("btn-danger").addClass("disabled");
                    $(".VideoRecordStatusTxt").addClass("recordMark").text("正在录制...");
                    setTimeout(function () {
                        $(".RecordVideo").removeClass("disabled");
                    }, 3000);
                    top.myService.StartRecordVideo(sessionStorage.CurrentExperimentId, parseInt(sessionStorage.syIndex));
                }
                else {
                    $("#VideoRecordStatus").val(0);
                    $(".RecordVideo").text("开始录制").removeClass("btn-danger").addClass("btn-success").addClass("disabled");
                    $(".VideoRecordStatusTxt").removeClass("recordMark").text("未在录制");
                    setTimeout(function () {
                        $(".RecordVideo").removeClass("disabled");
                    }, 3000);
                    top.myService.StopRecordVideo();
                }


            });
            $(".splj-btn").click(function () {
                top.layer.open({
                    title: "视频目录配置",
                    type: 2,
                    shadeClose: false, //必须点弹窗关闭按钮关闭
                    shade: 0.1,
                    closeBtn: 1,
                    move: false,
                    area: ['500px', '260px'], //宽高
                    btn: ['保存', '取消'],
                    content: ['VideoSetting.html', 'no'],
                    yes: function (index, layero) {

                        if (top.sysControl.SaveVideoPath(top.frames[$(layero).find("iframe").prop("name")].getVal()) == "ok") {
                            top.layer.close(index);
                            top.layer.msg("保存成功")
                        }
                    }
                });

            });
            $(".OpenVideoPath").click(function () {
                top.myService.OpenExplore(sessionStorage.CurrentExperimentId, parseInt(sessionStorage.syIndex));
            });
            $(".start-shiyan").click(function () {
                layer.confirm(
                    "<span style='font-weight:bolder'>您确定要开始本次试验么？</span>",
                    { btn: ['是的，我确定开始！', '我还没有准备好'],
                        icon: 0,
                        shade: 0.01,
                        title: '操作确认',
                        offset: '3px',
                        closeBtn: 0,
                        move: false },
                    function (index) {
                        layer.close(index);


                        startTime = new Date().getTime();
                        var loadingIndex = top.layer.msg('正在准备开始试验...', {
                            time: 0, icon: 16, shade: 0.01
                        });
                        $.ajax({
                            url: sessionStorage.CurrentHttpAddress + "/insertExperimentStep",
                            type: "get",
                            data: {
                                experiment_id: sessionStorage.CurrentExperimentId,
                                start_time_stamp: startTime,
                                sywd: parseFloat(sessionStorage.Sywd).toFixed(2)
                            },
                            context: document.body,
                            success: function (res) {

                                if (res == 'NOTCLOSE')
                                {
                                    top.layer.msg("柜门未关闭，请先关闭柜门！", { offset:'t'});
                                    return
                                }
                                if (res.indexOf('error') != -1) {

                                    top.layer.msg(res, { offset: 't' });
                                    return
                                }
                                setTimeout(function () {

                                    sessionStorage.syIndex = parseInt(sessionStorage.syIndex) + 1;
                                    socket = io.connect(sessionStorage.CurrentHttpAddress + "/temp");
                                    top.layer.close(loadingIndex);
                                    $(".startTimeTxt").text(timestampToTime(startTime));
                                    $(".shiyan-status").eq(1).show().siblings('.shiyan-status').hide();
                                    $(".start-shiyan").addClass("disabled").text("正在试验中...");
                                    $(".ControlMask").hide();

                                    experimentStepId = res;
                                    $(".RecordVideo").eq(0).trigger("click");

                                    var totalSesond = parseFloat(sessionStorage.Sysc) * 3600;
                                    var kgAlertIndex = 0;
                                    var fqAlertIndex = 0;
                                    var nomarl = false;
                                    socket.on('server_temp', function (res) {
                                        var tempTuple = res.split(',');
                                        temp1 = parseFloat(tempTuple[0]);
                                        temp2 = parseFloat(tempTuple[1]);
                                        temp3 = parseFloat(tempTuple[2]);
                                        kg = parseInt(tempTuple[3]);
                                        fq = parseInt(tempTuple[4]);
                                        temp4 = parseFloat(tempTuple[5]);
                                        if (temp4 != '0' && nomarl == false) {
                                            startTime = new Date().getTime();
                                            nomarl = true;
                                            $(".shiyan-status").eq(2).show().siblings(".shiyan-status").hide();
                                        }
                                        if (parseInt(temp2) > 0) {
                                            $(".shiyan-hxwd").text("烘箱温度：" + temp2 + "℃");
                                        }
                                    });
                                    setInterval(function () {
                                        if (shiyan) {
                                            currentShiYanTime = new Date().getTime();
                                            var jsTime = currentShiYanTime - startTime;
                                            t = jsTime / 100;
                                            $("#shiyan-time").text("已用时：" + (Math.floor(t / 36000)) + "时" + Math.floor((t % 36000) / 600) + "分" + ((t % 600) / 10).toFixed(1) + "秒");


                                            if (kg == 1) {
                                                if (kgMark == 0 && (kgStartTime == 0 || (kgStartTime != 0 && (currentShiYanTime - kgStartTime) >= 60000))) {
                                                    kgMark = 1;
                                                    kgStartTime = 0;
                                                    AjaxGet("", "openBeep", null, function (res) {

                                                    });
                                                    AjaxGet("", "closeMotor", null, function (res) {

                                                    });
                                                    if (kgAlertIndex == 0) {
                                                        kgAlertIndex = top.layer.alert(
                                                            "<span style='font-weight:bolder;color:red'>请关闭柜门！</span><br/>确认后1分钟内不提示",
                                                            {
                                                                icon: 0, title: '警告', offset: '3px', shade: 0, time: 0, closeBtn: 0, move: false, end: function () {
                                                                    kgMark = 0;
                                                                    kgAlertIndex=0
                                                                    AjaxGet("", "closeBeep", null, function (res) {

                                                                    });
                                                                    AjaxGet("", "openMotor", null, function (res) {

                                                                    });
                                                                }
                                                            },
                                                            function (index) {
                                                                kgStartTime = new Date().getTime();
                                                                kgAlertIndex = 0;
                                                                kgMark = 0;
                                                                top.layer.close(index);
                                                                AjaxGet("", "closeBeep", null, function (res) {

                                                                });
                                                                AjaxGet("", "openMotor", null, function (res) {

                                                                });
                                                            }
                                                        );
                                                    }
                                                }
                                            } else {

                                                if (kgAlertIndex != 0) {
                                                    top.layer.close(kgAlertIndex);
                                                    kgAlertIndex = 0;
                                                    kgMark = 0;
                                                }

                                            }

                                            if (fq == 1) {
                                                if (fqMark == 0 && (fqStartTime == 0 || (fqStartTime != 0 && (currentShiYanTime - fqStartTime) >= 60000))) {
                                                    fqMark = 1;
                                                    fqStartTime = 0;
                                                    AjaxGet("", "openBeep", null, function (res) {

                                                    });
                                                    if (fqAlertIndex == 0) {
                                                        fqAlertIndex = top.layer.alert(
                                                            "<span style='font-weight:bolder;color:red'>水浴液位过低！</span><br/>确认后1分钟内不提示",
                                                            {
                                                                icon: 0, title: '警告', offset: '3px', shade: 0, time: 5000, closeBtn: 0, move: false, end: function () {
                                                                    fqMark = 0;
                                                                    fqAlertIndex = 0;
                                                                    AjaxGet("", "closeBeep", null, function (res) {

                                                                    });
                                                                }
                                                            },
                                                            function (index) {
                                                                fqStartTime = new Date().getTime();
                                                                fqAlertIndex = 0;
                                                                fqMark = 0;
                                                                top.layer.close(index);
                                                                AjaxGet("", "closeBeep", null, function (res) {

                                                                });
                                                            }
                                                        );
                                                    }
                                                }
                                            }
                                            else {
                                                if (fqAlertIndex != 0) {
                                                    top.layer.close(fqAlertIndex);
                                                    fqAlertIndex = 0;
                                                    fqMark = 0;
                                                }
                                            }
                                            if (jsTime >= (totalSesond * 1000)) {
                                                shiyan = false;
                                                startExperimentMark = false;
                                                AjaxGet("", "openWarn", null, function (res) {

                                                });
                                                layer.open({
                                                    title: "试验结束现象确认",
                                                    type: 1,
                                                    shadeClose: false, //必须点弹窗关闭按钮关闭
                                                    shade: 0.2,
                                                    closeBtn: 0,
                                                    move: false,
                                                    area: ['550px', '150px'], //宽高
                                                    content:
                                                    '<div style="margin-top:22px;margin-left:35px;" class="btn-group syxx1"><button type="button" class="btn stopExperiment" onclick="endOpera(this)" value="1">试样爆炸</button>' +
                                                    '<button type="button" class="btn stopExperiment" onclick="endOpera(this)" value="2">试样燃耗</button>' +
                                                    '<button type="button" class="btn stopExperiment" onclick="endOpera(this)" value="3">试样变色</button>' +
                                                    '<button type="button" class="btn stopExperiment" onclick="endOpera(this)" value="0">无变化</button></div>'
                                                });
                                                //var nextType = parseInt(sessionStorage.syIndex) == 1 ? 1 : 2;
                                                //completion(nextType, 0, 0, 1, function () {
                                                //    top.layer.alert(
                                                //        "<span style='font-weight:bolder;color:red'>本次试验已经完成！</span>",
                                                //        { icon: 0, title: '操作确认', offset: '3px', closeBtn: 0, move: false },
                                                //        function (index) {
                                                //            top.layer.close(index);
                                                //            AjaxGet("正在关闭警报...", "closeBeep", null, function (res) {
                                                //                parent.stepNext();
                                                //                if (nextType == 2) {
                                                //                    parent.stepNext();
                                                //                }
                                                //                //parent.stepNext();
                                                //            });
                                                //        }
                                                //    );
                                                //});

                                            }
                                        }

                                    }, 50);

                                    startExperimentMark = true;
                                //$(".content-frame").each(function () {

                                //    $(this).contents().find("#Sycl").text(txtSycl);
                                //    $(this).contents().find("#cupNum").text(cupNum);
                                //})
                                }, 5000);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(errorThrown);
                            }
                        });
                    },
                    function () {
                        return;
                    }
                );

            });
            $(".stopExperiment").click(function () {
                var that = this;
                top.layer.confirm(
                    "您确定发现了<span style='font-weight:bolder;color:red'>“" + ($(that).text()) + "”</span>试验现象么？<br/><span style='font-weight:bolder'>确认后本次试验将结束！</span>",
                    { btn: ['是的，我确认！', '不小心点错了'], icon: 0, title: '操作确认', offset: '3px', closeBtn: 0, move: false },
                    function (index) {
                        top.layer.close(index);
                        var nextType = parseInt(sessionStorage.syIndex) == 1 ? 1 : 2;
                        if ($(that).val() != '0') {
                            nextType = 2;
                        }
                        completion(nextType, 0, $(that).val(), 0);
                    },
                    function () {

                    }
                );

            })
            $(".sxt-btn").click(function () {

                if ($(this).text() == "查看实时图像") {
                    $(this).text("查看试验详情")
                    $("#videoControl").show();
                    $("#sycontent").css("overflow-y", "hidden");
                }
                else {
                    $(this).text("查看实时图像")
                    $("#sycontent").css("overflow-y", "scroll");
                    $("#videoControl").hide();
                }
            });
            $(".fm-btn").click(function () {
                if ($(this).text() == "关闭阀门") {
                    $(".fm-btn").text("开启阀门")
                    top.sys.motosAuto(2);
                } else {
                    $(".fm-btn").text("关闭阀门")
                    top.sys.motosAuto(1);
                }
            });
            $(".OpenLight").click(function () {
                var swichVal = $(this).attr("val");
                var lightFlag = swichVal == '0' ? "openLight" : "closeLight";
                if (swichVal == '0') {

                    $(this).text("关灯");
                    $(this).attr("val", '1');
                    $.get('http://'+sessionStorage.CurrentIP+':8080/?action=command&dest=0&plugin=0&id=10094850&group=1&value=30');
                } else {

                    $(this).text("开灯");
                    $(this).attr("val", '0');
                    $.get('http://'+sessionStorage.CurrentIP+':8080/?action=command&dest=0&plugin=0&id=10094850&group=1&value=180');
                }

                AjaxGet("", lightFlag, null, function (res) {

                });

            });
            $(".home-btn").click(function () {

                //if ($(".sxt-btn").text() != "查看摄像头") {
                //    $("#bh").text("实验温度")
                //    $(".sxt-btn").text("查看摄像头")
                //    top.sys.hideCamera();
                //}
                layer.confirm(
                    "您确定要退出本次试验么？<br/><span style='font-weight:bolder'>退出后本阶段试验数据不再保存！</span>",
                    { btn: ['是的，我确定结束！', '不小心点错了'],
                        icon: 0,
                        title: '操作确认',
                        offset: '3px',
                        closeBtn: 0,
                        shade: 0.01,
                        move: false },
                    function (index) {
                        layer.close(index);
                        completion(0,0,0,0);
                    },
                    function () {

                    }
                );
                //swal({
                //    title: "您确定要结束本次“标准试验”流程么？",
                //    text: "结束后系统将跳转至主界面，且本次试验数据不再保持！",
                //    type: "warning",
                //    animation: false,
                //    showCancelButton: true,
                //    cancelButtonText: "不小心点错了",
                //    confirmButtonColor: "#DD6B55",
                //    confirmButtonText: "是的，我确定结束！",
                //    closeOnConfirm: false
                //}, function () {
                //    $("#userinfo-btn", top.document).removeClass("disabled");
                //    top.dataOpera.stopDisplayTemp();
                //    $("#content-frame", top.document).attr("src", "Menu.html");
                //    $("#menu-title", top.document).removeClass().addClass("fa fa-home").text(" 功能菜单");

                //});

            });


        })
        function endOpera(that) {
            top.layer.confirm(
                "您确定发现了<span style='font-weight:bolder;color:red'>“" + ($(that).text()) + "”</span>试验现象么？<br/><span style='font-weight:bolder'>确认后本次试验将结束！</span>",
                { btn: ['是的，我确认！', '不小心点错了'], icon: 0, title: '操作确认', offset: '3px', closeBtn: 0, move: false },
                function (index) {
                    AjaxGet("", "closeBeep", null, function (res) {

                    });
                    top.layer.close(index);
                    var nextType = parseInt(sessionStorage.syIndex) == 1 ? 1 : 2;
                    if ($(that).val() != '0') {
                        nextType = 2;
                    }
                    completion(nextType, 0, $(that).val(), 0);
                },
                function () {

                }
            );
        }
        function completion(type, tempStatus, sampleStatus, isOpenBeep, fun) {

            shiyan = false
          /* top.myService.HideCamera();
            top.myService.StopRecordVideo(); */
            $("#videoControl").hide();
            var ltxt = type == 0 ? "正在结束试验..." : '正在保存试验数据...';
            var loadingIndex = top.layer.msg(ltxt, {
                time: 0, icon: 16, shade: 0.01
            });
            var firstResult = "";
            if (parseInt(sessionStorage.syIndex) == 1) {
                sessionStorage.tempStatus1 = tempStatus;
                sessionStorage.sampleStatus1 = sampleStatus
                //firstResult += sampleStatus == 0 ? "试验现象未确认，" : `试样发生“${getSampleStatusStr(sampleStatus)}”现象，`;
                //firstResult += `“${(tempStatus==1?"未出现":"出现")}”试样自加热温度超过10秒钟大于等于3℃情况`;
            } else {
                sessionStorage.tempStatus2 = tempStatus;
                sessionStorage.sampleStatus2 = sampleStatus
            }
            $.ajax({
                url: sessionStorage.CurrentHttpAddress + "/stopExperimentStep",
                type: "get",
                data: {
                    experiment_step_id: experimentStepId, stot_time_stamp: currentShiYanTime,
                    time_cost: (currentShiYanTime - startTime), isOpenBeep: isOpenBeep,
                    tempStatus: tempStatus, sampleStatus: sampleStatus
                },
                context: document.body,
                success: function (res) {

                    top.layer.close(loadingIndex);
                    if (res != '1') {
                        //top.layer.alert(res);
                    }

                    switch (type) {
                        case 0:
                            $("#userinfo-btn", top.document).removeClass("disabled");
                            $("#content-frame", top.document).attr("src", "Menu.html");
                            $("#menu-title", top.document).removeClass().addClass("fa fa-home").text(" 功能菜单");
                            break;
                        case 1:
                            if (isOpenBeep==0) {
                                parent.stepNext();
                            }
                            if (fun != null) {
                                fun();
                            }
                            break;
                        case 2:
                            var result = '';
                            result += sampleStatus
                            $.ajax({
                                url: sessionStorage.CurrentHttpAddress + "/updateExperiment",
                                type: "get",
                                data: {
                                    experiment_id: sessionStorage.CurrentExperimentId,
                                    total_count: parseInt(sessionStorage.syIndex),
                                    result: ''
                                },
                                success: function (res) {
                                    if (isOpenBeep == 0) {
                                        parent.stepNext();
                                        parent.stepNext();
                                    }
                                    if (fun != null) {
                                        fun();
                                    }
                                    $('#content-frame3', window.parent.document).attr("src", "Result.html?experimentId=" + sessionStorage.CurrentExperimentId);

                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    if (error == null) {
                                        alert(errorThrown);
                                    }
                                    else {
                                        error(errorThrown);
                                    }
                                }
                            });


                        default:
                    }


                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });

        }
        function pjz(time1, time2) {

            var cha = Math.abs(Number(time2) - Number(time1)) / 10;
            var pj = ((Number(time2) + Number(time1)) / 20);

            return pj;
        }
        function xs(time1, time2) {

            var cha = Math.abs(Number(time2) - Number(time1)) / 10;
            var pj = ((Number(time2) + Number(time1)) / 20);

            return cha / pj;
        }
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });

        Highcharts.chart('flot-line-chart-moving1', {
            chart: {
                type: 'spline',
                animation: Highcharts.svg, // don't animate in old IE
                marginRight: 10,
                events: {
                    load: function () {

                        // set up the updating of the chart each second
                        var series = this.series[0];
                        var series1 = this.series[1];
                        setInterval(function () {
                            if (startExperimentMark) {
                                var x = (new Date()).getTime(); // current time
                                series.addPoint([x, temp2 < 1 ? null : temp2], true, true);
                            }

                        }, 1000);
                    }
                }
            },
            title: {
                text: '烘箱实时温度监测'
            },
            xAxis: {
                type: 'datetime',
                tickPixelInterval: 150
            },
            yAxis: {
                //max: 100,
                title: {
                    text: '温度 ℃'
                },
                //plotLines: [{
                //    label: {
                //        text: '我是标示线的标签',     //标签的内容
                //        align: 'left',                //标签的水平位置，水平居左,默认是水平居中center
                //        x: 10                         //标签相对于被定位的位置水平偏移的像素，重新定位，水平居左10px
                //    },
                //    value: 30,
                //    width: 2,
                //    color: '#808888'
                //}]
            },
            plotOptions: {
                spline: {
                    lineWidth: 2,
                    states: {
                        hover: {
                            lineWidth: 3
                        }
                    },
                    marker: {
                        enabled: false
                        //radius: 10
                    },
                    pointInterval: 3600000, // one hour
                    pointStart: Date.UTC(2009, 9, 6, 0, 0, 0)
                }
            },
            tooltip: {
                formatter: function () {
                    return '<b>' + this.series.name + '</b><br/>' +
                        Highcharts.dateFormat('时间：%Y-%m-%d %H:%M:%S', this.x) + '<br/>温度：' +
                        Highcharts.numberFormat(this.y, 2) + '℃';
                }
            },
            legend: {
                enabled: false
            },
            exporting: {
                enabled: false
            },
            series: [

                {
                    name: '烘箱温度',
                    marker: {
                        symbol: 'square1'
                    },
                    data: (function () {
                        // generate an array of random data
                        var data = [],
                            time = (new Date()).getTime(),
                            i;

                        for (i = -59; i <= 0; i += 1) {
                            data.push({
                                x: time + i * 1000,
                                y: null
                            });
                        }
                        return data;
                    }())
                }
            ]
        });

        Highcharts.chart('flot-line-chart-moving2', {
            chart: {
                type: 'spline',
                animation: Highcharts.svg, // don't animate in old IE
                marginRight: 10,
                events: {
                    load: function () {

                        // set up the updating of the chart each second
                        var series = this.series[0];
                        var series1 = this.series[1];
                        setInterval(function () {
                            if (startExperimentMark) {
                                var x = (new Date()).getTime(); // current time
                                series.addPoint([x, temp3 < 1 ? null : temp3], true, true);
                            }

                        }, 1000);
                    }
                }
            },
            title: {
                text: '烘箱实时温度监测（辅助）'
            },
            xAxis: {
                type: 'datetime',
                tickPixelInterval: 150
            },
            yAxis: {
                title: {
                    text: '温度 ℃'
                },
            },
            plotOptions: {
                spline: {
                    lineWidth: 2,
                    states: {
                        hover: {
                            lineWidth: 3
                        }
                    },
                    marker: {
                        enabled: false
                        //radius: 10
                    },
                    pointInterval: 3600000, // one hour
                    pointStart: Date.UTC(2009, 9, 6, 0, 0, 0)
                }
            },
            tooltip: {
                formatter: function () {
                    return '<b>' + this.series.name + '</b><br/>' +
                        Highcharts.dateFormat('时间：%Y-%m-%d %H:%M:%S', this.x) + '<br/>温度：' +
                        Highcharts.numberFormat(this.y, 2) + '℃';
                }
            },
            legend: {
                enabled: false
            },
            exporting: {
                enabled: false
            },
            series: [

                {
                    name: '烘箱温度（辅助）',
                    marker: {
                        symbol: 'square1'
                    },
                    data: (function () {
                        // generate an array of random data
                        var data = [],
                            time = (new Date()).getTime(),
                            i;

                        for (i = -59; i <= 0; i += 1) {
                            data.push({
                                x: time + i * 1000,
                                y: null
                            });
                        }
                        return data;
                    }())
                }
            ]
        });
    </script>
</body>
</html>
